include $(TOPDIR)/rules.mk

PKG_NAME:=adbyby
PKG_VERSION:=2.1.0
PKG_RELEASE:=1

include $(INCLUDE_DIR)/package.mk

define Package/adbyby
SECTION:=net
CATEGORY:=Network
SUBMENU:=Routing and Redirection
DEPENDS:=
TITLE:=AD Bye Bye
PKGARCH:=all
endef

define Package/adbyby/description
ADBYBY is a tools to remove AD from internet browsing.
endef

define Build/Compile
endef

define Package/adbyby/postinst
#!/bin/sh
( . /etc/uci-defaults/adbyby ) && rm -f /etc/uci-defaults/adbyby
exit 0
endef

define Package/adbyby/prerm
#!/bin/sh
uci -q batch <<-EOF >/dev/null
	delete firewall.adbyby
	commit firewall
EOF
/etc/init.d/adbyby disable >/dev/null 2>&1
exit 0
endef

define Package/adbyby/install
	$(CP) ./root/* $(1)
	$(INSTALL_DIR) $(1)/usr/bin
	$(INSTALL_BIN) ./root/usr/bin/adbyby $(1)/usr/bin/adbyby
	$(INSTALL_DIR) $(1)/etc/init.d
	$(INSTALL_BIN) ./files/adbyby.init $(1)/etc/init.d/adbyby
	$(INSTALL_DIR) $(1)/etc/config
	$(INSTALL_CONF) ./files/adbyby.config $(1)/etc/config/adbyby
	$(INSTALL_DIR) $(1)/etc
	$(INSTALL_BIN) ./files/adbyby.firewall $(1)/etc/firewall.adbyby
	$(INSTALL_DIR) $(1)/etc/uci-defaults
	$(INSTALL_BIN) ./files/adbyby.uci $(1)/etc/uci-defaults/adbyby
endef

$(eval $(call BuildPackage,adbyby))
